#include <ncurses.h>

#include "Tilemap.h"
#include "Tile.h"
#include "Curses.h"
#include "MapWindow.h"

MapWindow::MapWindow(int width, int height, int x, int y, Level* level)
 : Window(width, height, x, y, true), m_targetLevel(level)
{

}

void MapWindow::output() {
	Curses curses = Curses::instance();
	Tilemap* tilemap = m_targetLevel->tilemap();
	for (int i = 0; i < tilemap->height(); i++) {
		for (int j = 0; j < tilemap->width(); j++) {
			Tile tile = tilemap->tile(j, i);
			
			enableAttributes(COLOR_PAIR(tile.symbol.color));
			// Add + 1 since the window has a border.
			curses.putchar(this, j + 1, i + 1, tile.symbol.symbol);
			disableAttributes(COLOR_PAIR(tile.symbol.color));
		}
	}
}
/*
void MapWindow::refresh() {
	
	Window::refresh();
}
*/